package com.shopping.runbackground.coupons.service.impl;





import com.github.pagehelper.PageHelper;
import com.shopping.runbackground.coupons.api.pojo.StoreCoupons;
import com.shopping.runbackground.coupons.dao.StoreCouponsDao;
import com.shopping.runbackground.coupons.service.StoreCouponsService;

import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

/**
 * (StoreCoupons)表服务实现类
 *
 * @author makejava
 * @since 2020-06-02 10:30:24
 */
@Service("storeCouponsService")
public class StoreCouponsServiceImpl implements StoreCouponsService {
    @Resource
    private StoreCouponsDao storeCouponsDao;


    /**
     * 查询所有数据
     *
     * @param sid
     * @param ename
     * @param currentPage
     * @param pageSize
     */
    @Override
    public List<StoreCoupons> queryAllByLimits(String sid, String ename, Integer currentPage, Integer pageSize) {

        PageHelper.startPage(currentPage, pageSize);
        Example example = new Example(StoreCoupons.class);
        Example.Criteria criteria = example.createCriteria();
        if(ename!=null){
            criteria.andLike("sc_name",ename);
        }
        if(sid!=null){
            criteria.andLike("s_id",sid);
        }
        List<StoreCoupons> storeCoupons1 = storeCouponsDao.selectByExample(example);
        return storeCoupons1;
    }

    @Override
    public List<StoreCoupons> findall() {

        List<StoreCoupons> storeCoupons = storeCouponsDao.queryAllByLimits();
        return storeCoupons;
    }
}